/* Copyright (c) 2010, Peter Lényi */
/* Licensed under The BSD License. */

package gem.apps.fs.db;

import gem.apps.fs.entities.FileMeta;
import java.util.List;

/**
 * Interface DatabaseManager defines API for the database storage.
 * 
 * @author Peter Lényi
 * @version 20100425F
 */
public interface DatabaseManager
{
    /**
     * List all file meta data records in the database.
     * @return all file meta data.
     * @throws DatabaseCallException
     *          if an exception occured and rollback was performed.
     */
    List<FileMeta> listFileMeta() throws DatabaseCallException;

    /**
     * List a subset of file meta data records in the databse.
     * @param pageSize
     *          number of records returned.
     * @param pageNumber
     *          defines number of records skipped; first page has number 1.
     * @return subset of file meta data.
     * @throws DatabaseCallException
     *          if an exception occured and rollback was performed.
     */
    List<FileMeta> listFileMeta(int pageSize, int pageNumber) throws DatabaseCallException;

    /**
     * Insert a file meta data record in the database.
     * @param meta
     *          file meta data.
     * @throws DatabaseCallException
     *          if an exception occured and rollback was performed.
     */
    void insertFileMeta(FileMeta meta) throws DatabaseCallException;

    /**
     * Retrieve a file meta data record from the databse.
     * @param meta
     *          file meta data with key filled.
     * @return file meta data record.
     * @throws DatabaseCallException
     *          if an exception occured and rollback was performed.
     */
    FileMeta selectFileMeta(FileMeta meta) throws DatabaseCallException;

    /**
     * Update a file meta data record in the database. Certain data can not be
     * altered.
     * @param meta
     *          new file meta data with old key.
     * @throws DatabaseCallException
     *          if an exception occured and rollback was performed.
     */
    void updateFileMeta(FileMeta meta) throws DatabaseCallException;

    /**
     * Delete a file meta data record from the database.
     * @param meta
     *          file meta data with old key.
     * @throws DatabaseCallException
     *          if an exception occured and rollback was performed.
     */
    void deleteFileMeta(FileMeta meta) throws DatabaseCallException;
}
